package com.example.warehouse.mapper;

import com.example.warehouse.entity.AuthRode;
import com.example.warehouse.entity.Role;
import com.example.warehouse.page.Page1;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RoleMapper {
    public List<Role> findAllRole();

    List<Role> QueryByUid(Integer userId);

    //根据用户名查id
    @Select("SELECT role_id from role where role_name=#{RolaName}")
    Integer findUserId(String RoleName);


    Integer FindRoleRowCount(Role role);


    List<Role> FindRoleList(@Param("page") Page1 page1, @Param("role") Role role);

    @Delete("DELETE FROM role where role_id=#{roleId}")
    void deleteById(Integer roleId);

    @Update("update role set role_state=#{roleState} ,update_time=#{updateTime},update_by=#{updateBy} where role_id=#{roleId} ")
    void updateRoleState(Role role);

    @Update("update role set role_desc =#{roleDesc} ,update_time=#{updateTime},update_by=#{updateBy} where role_id=#{roleId}")
    void updataRoleById(Role role);


    @Insert("insert into role (role_name, role_desc, role_code, role_state, create_by, create_time) values" +
            " (#{roleName},#{roleDesc},#{roleCode},#{roleState},#{createBy},#{createTime})")
    void addRole(Role role);


    List<Integer> FindRoleAuth(Integer roleId);

    @Delete("delete from role_auth where role_id=#{roleId}")
    void deleteAuthByRole(Integer roleId);


    void addAuthByRoleId(AuthRode authRode);
}
